package com.example.springboot01.profile;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @Description : 手动选择代码执行环境
 * <p>
 * 使用ActiveProfiles属性，相当于配置文件中的spring.profiles.active属性
 * <p>
 * Created by cyd on 2021-04-30 23:11:00
 */
public class TestMain {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.getEnvironment().setActiveProfiles("pro");
        context.register(ProfileConfig.class);
        context.refresh();

        DemoBean bean = context.getBean(DemoBean.class);
        System.out.println(bean.getContent());
        context.close();
    }
}
